import org.kie.dmn.feel.lang.ast.ASTNode;
import org.kie.dmn.feel.lang.ast.BaseNode;

/**
 * @author 曹行阳
 * @version 0.1
 * @date 2025/6/17 19:03
 */
public class AstPrinter {
    public static void printAst(BaseNode node) {
        printAst(node, 0);
    }

    private static void printAst(BaseNode node, int indent) {
        if (node == null) return;

        String indentStr = "  ".repeat(indent);
        System.out.println(indentStr + node.getClass().getSimpleName() + ": " + node.getText());

        if (node.getChildrenNode() != null) {
            for (ASTNode child : node.getChildrenNode()) {
                printAst((BaseNode) child, indent + 1);
            }
        }
    }
}
